<?php $initialRequest = !$sf_request->isXmlHttpRequest(); ?>
<!DOCTYPE html>
<html<?php if (jfPortableDevice::getConfig('useManifest')): ?> manifest="<?php echo url_for('jfPortableDevice_manifest') ?>"<?php endif; ?> class="jfPD">
	<?php
	slot('page_assets');
	  include_component('jfPortableDevice', 'includeAssetsForPage');
	end_slot();    
	?>
  <?php if ($initialRequest): ?>
	<head>
    <?php
    if (!$sf_response->getTitle()) {
    	$sf_response->setTitle(jfPortableDevice::getPageTitle(jfPortableDevice::getConfig('appTitle')));
    }
    include_title();
    include_metas();
    include_component('jfPortableDevice', 'includeAssetsForApp');
    $theme = jfPortableDevice::getConfig('jfPDTheme');
    ?>
    <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1" />
    <link rel="apple-touch-icon" href="<?php echo $theme ?>/img/icon.png" />
	  <link rel="apple-touch-startup-image" href="<?php echo $theme ?>/img/startup.png" />
    <link rel="canonical" href="<?php echo htmlspecialchars(jfPortableDevice::cleanUrl($sf_data->getRaw('sf_request')->getUri())) ?>" />
    <?php include_component('jfPortableDevice', 'initialize') ?>
	</head>
  <?php endif; ?>
<body>
<?php
$pageAttributes = jfPortableDevice::getConfig('pageAttributes', array());
$pageAttributesAsString = '';
foreach ($pageAttributes as $key => $value) {
  $pageAttributesAsString .= ' '.$key.'="'.$value.'"';
}
?>
<div <?php echo $pageAttributesAsString ?> class="<?php if (has_slot('jfPD_bodyCssClass')): ?> <?php include_slot('jfPD_bodyCssClass') ?><?php endif; ?>">
<?php if (!jfPortableDevice::isNativeApp() || !$initialRequest): ?>
  <?php
  include_partial('jfPortableDevice/requireAppVersion');
  include_slot('page_assets');
  include_partial('jfPortableDevice/header');
  ?>
  <div data-role="content" >
    <?php echo $sf_content; ?>
  </div>
  <?php include_partial('jfPortableDevice/footer') ?> 
<?php endif; ?>
</div>
<?php if ($initialRequest): ?>
  <?php include_partial('jfPortableDevice/offline'); ?>
<?php endif; ?>
</body>
</html>
